<input id="hidden_goodsid" type="hidden" value="{$goods_info.goods_id}">
<input id="hidden_skuid"   type="hidden" value="">
<input id="hidden_skuname" type="hidden" value="">
<input id="hidden_sku_price" type="hidden" value="">
<input id="hidden_default_img_id" type="hidden" value="{$goods_info['img_list'][0]['pic_id']}" />
<input id="hidden_max_buy" type="hidden" value="{$goods_info.max_buy}" />
<input id="hidden_stock" type="hidden" value="{$goods_info.stock}" />
<input id="hidden_point_exchange_type" type="hidden" value="{$goods_info.point_exchange_type}"/>
<input id="hidden_point_exchange" type="hidden" value="{$goods_info.point_exchange}"/>
<input type="hidden" id="hidden_province" value="{$user_location.province}" />
<input type="hidden" id="hidden_city" />
<input type="hidden" id="hidden_shipping_fee_name" />
<input type="hidden" id="hidden_goods_type" value="{$goods_info.goods_type}" />
<!-- 头部右侧鼠标经过图片放大效果 _start -->
<script type="text/javascript" src="__TEMP__/{$style}/public/js/bubbleup.js"></script>
<!-- 头部右侧鼠标经过图片放大效果 _end -->
<!-- 右侧商品信息等定位切换效果 _start -->
<script type="text/javascript" src="__TEMP__/{$style}/public/js/ns_tabs_totop.js"></script>
<!-- 右侧商品信息等定位切换效果 _end -->
<!-- 放大镜 _start -->
<script type="text/javascript" src="__TEMP__/{$style}/public/js/magiczoom.js"></script>
{if condition="$goods_info.goods_type == 1"}
<!-- 地址选择 _start -->
<script type="text/javascript" src="__TEMP__/{$style}/public/js/ns_select_region.js"></script>
{/if}
<script type="text/javascript" src="__TEMP__/{$style}/public/js/tabs.js"></script>
<script type="text/javascript" src="__TEMP__/{$style}/public/js/goods.js"></script>
<script type="text/javascript">
//获取商品最小购买数量
var min_buy = parseInt($(".amount-input").attr("data-min"));
var sku_list = new Array();
var price_section_arr = {
	'promotion_price' : [],
	'member_price' : []
};
$().ready(function() {

	if($(".js-skulist input[type='hidden'][Js-sku='sku']").length > 0){
		$(".js-skulist input[type='hidden'][Js-sku='sku']").each(function(){
			sku_list.push($(this).val());
			var promotion_price = $(this).attr("promotion_price"),
				member_price = $(this).attr("member_price");
				price_section_arr.promotion_price.push(promotion_price);
				price_section_arr.member_price.push(member_price);
		})
		price_section_arr.promotion_price.sort();
		price_section_arr.member_price.sort();
	}

	// initGoodsInfo();
	initSku();//加载sku
	
	$(".magnifying-glass").click(function(){
		showPhotoSwipe();
	});
	
	$(".combo-package-promotion-buy").click(function(){
		var combo_id = $(this).attr("data-combo-id"); 
		var	curr_id = $(this).attr("data-curr-id");
		if($("#hidden_uid").val()==''){
			showPopLogin();
		}else{
			location.href = "{:__URL('SHOP_MAIN/goods/comboPackagePromotionSelected','combo_id="+combo_id+"&curr_id="+curr_id+"')}";
		}
	});
	
	//判断是否有总库存
	if(parseInt($("#hidden_stock").val())==0){
		$(".js-buy-now").addClass("disabled");
		$(".add-cart").addClass("disabled");
		$(".js-point-exchange").addClass("disabled");
	}

	if($("#hidden_shipping_fee_name").val() == "{:lang('goods_no_goods')}"){
		$(".js-buy-now").addClass("disabled");
		$(".add-cart").addClass("disabled");
		$(".js-point-exchange").addClass("disabled");
	}

	if($("#hidden_goods_type").val() == 1){
		//实物商品才会查询运费
		var goods_sku_list = $("#goods_sku0").attr("skuid") + ":1";
		//定位查询运费
		$.ajax({
			type : "post",
			data : { "goods_id" : "{$goods_info.goods_id}" ,"goods_sku_list" : goods_sku_list},
			url : "{:__URL('SHOP_MAIN/goods/getShippingFeeNameByLocation')}",
			success : function(data){
				if(data.user_location != null){
					$(".js-region").html("<font>" + data.user_location.province + data.user_location.city + "<i></i></font>").show();
					$(".region-tab[data-region-level=1]").html(data.user_location.province + "<i></i>");
					$(".region-tab[data-region-level=2]").html(data.user_location.city + "<i></i>");
					$("#hidden_province").val(data.user_location.province);
					$("#hidden_city").val(data.user_location.city);
					initAddress();
				}
	
				var html = "";
				if(data.express != null && data.express != ""){
					if(typeof data.express == "string"){
						html = '快递：' + data.express;
					}else if(typeof data.express == "object"){
						html = "<select>";
						for(var i=0;i<data.express.length;i++){
							html += '<option value="' + data.express[i].co_id + '">' + data.express[i].company_name + '&nbsp;&nbsp;&nbsp;¥' + data.express[i].express_fee + '</option>';
						}
						html += "</select>";
					}
				}else{
					// html = "{:lang('goods_no_goods')}";
					html = "本地区暂不支持配送";	
				}
				$(".js-shipping-name").html(html);
			}
		});
	}

	$("#goods_detail").click(function(){
		$(".title-list").removeClass('current');
		$(this).parent().addClass('current');
		$("#goods_introduce").show();
		$("#goods_attr_list").hide();
		$("#goods_evaluate").hide();
		$("#goods_consult").hide();
	});
	
	$("#goods_attribute").click(function(){
		$(".title-list").removeClass('current');
		$(this).parent().addClass('current');
		$("#goods_introduce").hide();
		$("#goods_attr_list").show();
		$("#goods_evaluate").hide();
		$("#goods_consult").hide();
	});
	
	$("#evaluate_count").click(function(){
		$(".title-list").removeClass('current');
		$(this).parent().addClass('current');
		$("#goods_introduce").hide();
		$("#goods_attr_list").hide();
		$("#goods_evaluate").show();
		$("#goods_consult").hide();
	});
	
	$("#goods_consultation").click(function(){
		$(".title-list").removeClass('current');
		$(this).parent().addClass('current');
		$("#goods_introduce").hide();
		$("#goods_attr_list").hide();
		$("#goods_evaluate").hide();
		$("#goods_consult").show();
	});
	
	$("#show_coupons").click(function(){
		var type = $("#show_coupons").text();
		if(type == '展开'){
			$("#show_coupons").find('span').text('收起');
			$("#show_coupons").find('img').attr('src','__TEMP__/{$style}/public/images/jiantouup.png');
		}
		if(type == '收起'){
			$("#show_coupons").find('span').text('展开');
			$("#show_coupons").find('img').attr('src','__TEMP__/{$style}/public/images/jiantou.png');
		}
		$("#coupons_detail").toggle();
	});

	$("#num").keyup(function(){
		var obj = $(this);
		var r = /^\d+$/;
		if(!r.test(obj.val())){
			if(min_buy > 0){
				obj.val(min_buy);
			}else{
				obj.val(1);
			}
			$.msg("{:lang('goods_enter_number')}");
		}else{
			if(parseInt(obj.val()) > parseInt(obj.attr("data-max"))){
				obj.val(obj.attr("data-max"));
			}
			//购买数不能小于最小购买数
			if(parseInt(obj.val()) < min_buy){
				obj.val(min_buy);
			}
			if(parseInt(obj.val()) <= 0){
				if(min_buy > 0){
					obj.val(min_buy);
				}else{
					obj.val(1);
				}
			}
		}
		calculated_price(obj.val(), "#price");
		calculated_price(obj.val(), "#member_price");
	})

	$(".amount-plus").click(function(){
		var obj = $("#num");
		var num = parseInt(obj.val());
		var max = parseInt(obj.attr("data-max"));
		var max_buy = parseInt($("#hidden_max_buy").val());
		num++;
		if(num > max) obj.val(max);
		else obj.val(num);
		calculated_price(obj.val(), "#price");
		calculated_price(obj.val(), "#member_price");
	})

	$(".amount-minus").click(function(){
		var obj = $("#num");
		var num = parseInt(obj.val());
		if(num > 1){
			num--;
			if(num < min_buy){
				$.msg("{:lang('minimum_purchase_amount_of_this_commodity')}"+min_buy);
				obj.val(min_buy);
			}else{
				obj.val(num);
			}
		}
		calculated_price(obj.val(), "#price");
		calculated_price(obj.val(), "#member_price");
	})
	
	//加载规格
	function initSku(){
		if(judge_is_all_selected()){
			var curr_sku = '';
			var sku_arr = $(".goods-spec-item");
			sku_arr.each(function(i) {
				var $this = $(this);
				if ($this.hasClass("selected")) {
					curr_sku += $this.find("span").attr("id") + ";";
				}
			});
			for (i = 0; i < parseInt($("#goods_sku_count").val()); i++) {

				sku_id = "#goods_sku" + i;
				goods_sku_id = $(sku_id).val();
				//修改匹配规则，不能直接等值判断。判断值是否存在即可
				var temp_curr_sku_array = curr_sku.split(";");
				var temp_goods_sku_id_array = goods_sku_id.split(";");
				var sku_count = 0;
				var curr_sku_count = 0;
				//匹配当前选中的SKU规格和商品SKU规格，检测是否都存在
				for(var j=0;j<temp_curr_sku_array.length;j++){
					sku_count++;
					if($.inArray(temp_curr_sku_array[j],temp_goods_sku_id_array) != -1) curr_sku_count++;
				}
				
				if (curr_sku_count == sku_count) {
					select_skuid = $(sku_id).attr("skuid");
					select_skuName = $(sku_id).attr("skuname");
					select_stock = $(sku_id).attr("stock");//sku商品库存
					original_price = parseFloat($(sku_id).attr("original_price")); //sku商品原价
					if(select_stock==0){
						$(".js-buy-now").addClass("disabled");
						$(".add-cart").addClass("disabled");
						$(".js-point-exchange").addClass("disabled");
					}else{
						//当最小购买数大于总库存时,不可购买
						if(min_buy > select_stock){
							$(".js-buy-now").addClass("disabled");
							$(".add-cart").addClass("disabled");
							$(".js-point-exchange").addClass("disabled");
						}else{
							$(".js-buy-now").removeClass("disabled");
							$(".add-cart").removeClass("disabled");
							$(".js-point-exchange").removeClass("disabled");
						}
					}
					$("#hidden_skuid").val(select_skuid);
					$("#hidden_skuname").val(select_skuName);
					var price = parseFloat($(sku_id).attr("price"));
					var promotion_price = parseFloat($(sku_id).attr("promotion_price"));
					var member_price = parseFloat($(sku_id).attr("member_price"));
					$("#price").text("￥" + promotion_price.toFixed(2));
					$("#price").attr("data-price", promotion_price.toFixed(2));
					$("#member_price").text("￥"+member_price.toFixed(2));
					$("#member_price").attr("data-price", member_price.toFixed(2));

					$(".market-price").text("￥" + original_price.toFixed(2));//商品原价
					$("#hidden_sku_price").val(price);
					$(".js-goods-number").text("{:lang('goods_stock')}"+select_stock+"{if condition ='empty($goods_info.goods_unit)'}件{else/}{$goods_info.goods_unit}{/if}");
					if($("#hidden_max_buy").val()==0 || parseInt($("#hidden_max_buy").val()) > parseInt($("#hidden_stock").val())){
						$(".amount-input").attr("data-max", select_stock);
					}else{
						$(".amount-input").attr("data-max", $("#hidden_max_buy").val());
					}
					
					//最小购买数为0时,购买数默认为1
					if(min_buy > 0) $(".amount-input").val(min_buy);
					else $(".amount-input").val(1);
					
					// 当只有一个sku时，不用验证
					if(parseInt($("#attribute_list").val()) == 0){
			 			select_specifications=true;//是否选择过规格,来源与shopping_cart.js
					}

					var integral_give_type = $("#integral_give_type").val();
					var hidden_give_point = $("#hidden_give_point").val();
					if(integral_give_type > 0 && hidden_give_point > 0){
						var sku_price = promotion_price < member_price ? promotion_price : member_price;
						var give_point = Math.round(sku_price * hidden_give_point * 0.01);
						$("#give_point").text(give_point);
					}
					break;
				}
			} 
		}else{
			$("#hidden_skuname").val("");
			$("#hidden_skuid").val("");
			var price_num = price_section_arr.promotion_price.length;
			if(price_num > 1 && price_section_arr.promotion_price[0] != price_section_arr.promotion_price[price_num -1]){
				$("#price").text("￥" + price_section_arr.promotion_price[0] + '-' + price_section_arr.promotion_price[price_num - 1]);
				$("#member_price").text("￥" + price_section_arr.member_price[0] + '-' + price_section_arr.member_price[price_num - 1]);
			}
		}
	}
	
	function initGoodsInfo(){
		//获取sku多图的主规格id
		var spec_id = $("#hide_spec_id").val();
		if(spec_id > 0){
			var firstSku = $("[id^="+spec_id+"]").eq(0);
			firstSku.parent().parent('.goods-spec-item').addClass("selected");
			if(firstSku.attr("id") != undefined){
				var sku_id = subSkuVue(firstSku.attr("id"));
				showSkuPicture(sku_id);
			}
		}
		
	}

	//截取sku属性值
	function subSkuVue(goods_sku_id){
		num = goods_sku_id.indexOf(":")+1;
		sku_vue_id = goods_sku_id.substr(num);
		return sku_vue_id;
	}

	//根据sku_id显示相册中的图片
	function showSkuPicture(sku_id){
		
		if($(".spec-items ul li#sku_pic_"+sku_id).length > 0){
			$(".spec-items ul li").hide();
			$(".spec-items ul li#sku_pic_"+sku_id).show();
			var firstPicUrl = $(".spec-items ul li img").not(":hidden").eq(0).attr("data_big_img");
			var picture_id = $(".spec-items ul li img").not(":hidden").eq(0).attr("data-picture-id");
			$(".spec-items ul li").not(":hidden").removeClass("on");
			$(".spec-items ul li").not(":hidden").eq(0).addClass("on");
			$(".MagTargetImg").attr("src",firstPicUrl);
			$(".MagTargetImg").attr("data_big_img",firstPicUrl);
			$("#hidden_default_img_id").val(picture_id);
		}
	}
	
	// 添加
	$(".add-cart,.js-buy-now,.js-point-exchange").click(function(event) {
		if($(this).hasClass("disabled") || $(this).hasClass("purchase-restriction")) return;
		if($(".amount-input").val() < min_buy){
			$.msg("{:lang('shall_not_less_than')}!");
			return;
		}
		var tag = $(this).attr("data-tag");
		var image_url = $("#MagnifierWrap .MagnifierMain").find("img").attr("src");
		var goodsid = {$goods_info.goods_id};
		$.cart.add(goodsid, $(".amount-input").val(), {
			is_sku: true,
			image_url: image_url,
			event: event,
			tag : tag
		});
	});

	// 添加对比
	$(".add-compare").click(function(event) {
		var target = $(this);
		var goods_id = $(this).data("goods-id");
		var sku_id = $(this).add("sku-id");
		var image_url = $(this).data("image-url");
		$.compare.toggle(goods_id, image_url, event, function(result) {
			if(result.data == 1) {
				$(target).addClass("curr");
			} else {
				$(target).removeClass("curr");
			}
		});
	});

	var is_member_fav_goods = {$is_member_fav_goods};
	// 添加收藏
	$(".collect-goods").click(function(event) {
		var num = $(this).find("span").attr("data-collects");
		var obj = $(this).find("span");
		if(is_member_fav_goods==0){
			//点击收藏
			$.ajax({
				url: "{:__URL('SHOP_MAIN/components/collectiongoodsorshop')}",
				type: "post",
				data: { "fav_id":{$goods_info.goods_id},"fav_type":"goods","log_msg":"{$goods_info.goods_name}"},
				success: function (data) {
					if(data.code>0){
						is_member_fav_goods = 1;
						num++;
						obj.attr("data-collects",num);
						obj.text("{:lang('goods_collection_goods')} ("+num+"{:lang('goods_popularity')})");
					}else{
						$.msg("{:lang('goods_already_collected')}");
					}
					$(".collect-goods").find("i").css("background-position","-112px -91px");
				}
			});
		}else if (is_member_fav_goods== 1){
			//取消收藏
			$.ajax({
				url: "{:__URL('SHOP_MAIN/components/cancelcollgoodsorShop')}",
				type: "post",
				data: { "fav_id":{$goods_info.goods_id},"fav_type":"goods","log_msg":"{$goods_info.goods_name}"},
				success: function (data) {
					if(data.code>0){
						num--;
						obj.attr("data-collects",num);
						obj.text("{:lang('goods_collection_goods')} ("+num+"{:lang('goods_popularity')})");
						$(".collect-goods").find("i").css("background-position","-112px -115px");
						is_member_fav_goods = 0;
					}else{
						$.msg("{:lang('goods_cancelled_collected')}");
					}
				}
			});
		}else{
			location.href=__URL("SHOP_MAIN/login/index");
		}
	});

	function sku_click_action(obj){
		$(obj).attr("data-last",1);
		var this_sku_vue = $(obj).find("span").attr("id");
		sku_vue = subSkuVue(this_sku_vue);
		showSkuPicture(sku_vue);

		initSku();

		//规格图片
		var show_big_pic = $(obj).find("span").attr("data-show-big-pic");
		if(show_big_pic != undefined && show_big_pic != ""){
			$(".MagTargetImg").attr("src", show_big_pic);
			$(".MagTargetImg").attr("data_big_img", show_big_pic);
			$(".spec-items ul li").removeClass("on");
		}else{
			//如果点击了文本，则默认选中第一个
			$(".MagTargetImg").attr("src", $(".spec-items ul li img").not(":hidden").eq(0).attr("data_big_img"));
			$(".MagTargetImg").attr("data_big_img", $(".spec-items ul li img").not(":hidden").eq(0).attr("data_big_img"));
			$(".spec-items ul li").not(":hidden").eq(0).addClass("on");
		}
		MagnifierF("MagnifierWrap");
	}

	// 点击选取规格
	$(".js-skulist li.goods-spec-item").click(function(){
		if($(this).hasClass('disabled')) return;
		if($(this).hasClass('selected')){
			$(this).removeClass('selected').siblings().removeClass('selected');
		}else{
			$(this).addClass('selected').siblings().removeClass('selected');
		}

		$(".js-skulist dl.attr").each(function(){
			if($(this).find('li.goods-spec-item.selected').length > 0){
				$(this).addClass('selected')
			}else{
				$(this).removeClass('selected')
			}
		})

		var not_exit_spec = get_not_exit_spec(get_selected_arr());
		$(".js-skulist dl.attr:not('.selected')").each(function(){
			set_sku_item_disabled($(this), not_exit_spec);
		})
		
		$(".js-skulist dl.attr").each(function(){
			update_same_level($(this));
		})

		sku_click_action($(this));
	})

	// 获取已经选中的规格
	function get_selected_arr(){
		var spec_value_arr = new Array();
		if($(".js-skulist li.goods-spec-item.selected").length > 0){
			$(".js-skulist li.goods-spec-item.selected").each(function(){
				spec_value_arr.push($(this).find("span").attr("id"));
			})
		}
		return spec_value_arr;
	}

	function get_not_exit_spec(selected_arr, not_select_arr){
		// 选取出可供继续匹配的sku数组
		var matching_arr = get_matching_arr(selected_arr);
		var new_arr = [];	
		for(i in matching_arr){
			matching_arr[i] = matching_arr[i].substr(0, matching_arr[i].length -1);
			new_arr = new_arr.concat(matching_arr[i].split(';'));
		}
		return new_arr;
	}

	// 获取全部符合选中项的sku
	function get_matching_arr(arr){
		var new_arr = new Array();
		for(i in sku_list){
			var _is_add = true;
			for(j in arr){
				if(sku_list[i].indexOf(arr[j]) == -1){
					_is_add = false;
					break;
				}
			}
			if(_is_add) new_arr.push(sku_list[i]);
		}
		return new_arr;
	}

	// 设置规格是否可选
	function set_sku_item_disabled(goods_spec, not_exit_spec){
		goods_spec.find("li.goods-spec-item").each(function(){
			var spec_id = $(this).find("span").attr("id");
			if(not_exit_spec.indexOf(spec_id) == -1){
				$(this).addClass("disabled");
			}else{
				$(this).removeClass("disabled");
			}
		})
	}

	// 设置同级是否可选
	function update_same_level(goods_spec){
		var selected_arr = get_selected_arr();
		var select_id = goods_spec.find("li.selected span").attr("id");
		var selected_arr_new = del_array_val(selected_arr, select_id);
		var not_exit_spec = get_not_exit_spec(selected_arr_new);
		set_sku_item_disabled(goods_spec, not_exit_spec);
	}

	function del_array_val(arr,val){
		//去除 数组 arr中的 val ，返回一个新数组
	    var new_arr = [];
	    for(k in arr){
	        if(arr[k] != val){
	            new_arr.push(arr[k]);
	        }
	    }
	    return new_arr;
	}

	// 判断规格是否全部选择
	function judge_is_all_selected(){
		var is_all_selected = true;
		if($("#attribute_list").val() > 0 && $(".js-skulist li.goods-spec-item.selected").length != $("#attribute_list").val()){
			is_all_selected = false;
		}
		return is_all_selected;
	}

	function skuDefaultSelect(){
		$(".js-skulist dl.attr:not('.selected')").each(function(){
			$(this).find('li.goods-spec-item').each(function(){
				var not_exit_spec = get_not_exit_spec(get_selected_arr());
				var spec_id = $(this).find("span").attr("id");
				if($.inArray(spec_id, not_exit_spec) != -1){
					$(this).trigger('click');
					return false;
				}
			})
			$(this).addClass('selected');
		})
	}

	// sku默认选中
	skuDefaultSelect();
});

//领取优惠劵
function coupon_receive(event,coupon_type_id){
	if($("#hidden_uid").val()==''){
		showPopLogin();
	}else{
		var data_at_least = $(event).attr("data-at-least");
		var data_money = $(event).attr("data-money");
		var data_start_time = $(event).attr("data-start-time");
		var data_end_time = $(event).attr("data-end-time");
		var data_max_fetch = parseInt($(event).attr("data-max-fetch"));
		var data_receive_quantity = parseInt($(event).attr("data-receive-quantity"));
		if(data_max_fetch != 0 && data_receive_quantity>= data_max_fetch){
			layer.open({
				type: 1,
				skin: 'layui-layer-rim', //加上边框
				area: ['420px', '200px'], //宽高
				title : '{:lang('receive_coupons')}',
				content: '<div class="tip-info"><div class="left"><i class="receiveTip"></i></div><div class="right"><p class="coupon_desc">{:lang('reached_the_limit')}！</p><p class="my_coupon">{:lang('view_the_collar_coupons')}：<a href="'+__URL('SHOP_MAIN/member/vouchers')+'" target="_blank">{:lang('my_discount_information')}</a></p></div></div>'

			});
			return false;
		}
		$.ajax({
			url : __URL("SHOP_MAIN/goods/receiveGoodsCoupon"),
			type : "post",
			data : { "coupon_type_id" : coupon_type_id},
			success : function(res){
				if(res['code']>0){
					$(".coupon"+coupon_type_id).attr("data-receive-quantity",data_receive_quantity+1);
					layer.open({
						type: 1,
						skin: 'layui-layer-rim', //加上边框
						area: ['420px', '200px'], //宽高
						title : '{:lang('receive_coupons')}',
						content: '<div class="tip-info"><div class="left"><i></i></div><div class="right"><p class="coupon_desc">{:lang('congratulations_on_your_success')}<span style="color:#FF0000;">{:lang('member_full')}'+data_at_least+'{:lang('element')}{:lang('member_reduce')}'+data_money+'{:lang('element')}</span>{:lang('coupon')}</p><p class="use_time">{:lang('use_time')}：'+data_start_time+'-'+data_end_time+'</p><p class="my_coupon">{:lang('view_the_collar_coupons')}：<a href="'+__URL('SHOP_MAIN/member/vouchers')+'"  target="_blank">{:lang('my_discount_information')}</a></p></div></div>'
					});
				}else if(res['code'] == -2011){
					layer.open({
						type: 1,
						skin: 'layui-layer-rim', //加上边框
						area: ['420px', '200px'], //宽高
						title : '{:lang('receive_coupons')}',
						content: '<div class="tip-info"><div class="left"><i class="receiveTip"></i></div><div class="right"><p class="coupon_desc">{:lang('has_brought_over')}！</p><p class="my_coupon">{:lang('view_the_collar_coupons')}：<a href="'+__URL('SHOP_MAIN/member/vouchers')+'" target="_blank">{:lang('my_discount_information')}</a></p></div></div>'
					});
				}else{
					layer.msg(res['message']);
				}
			}
		})
	}
}

//切换组合套餐	
$(".combo-package-promotion nav ul li").click(function(){
	$(".combo-package-promotion nav ul li").removeClass("selected");
	$(this).addClass("selected");
	var data_combo_id = $(this).attr("data-combo-id");
	$(".combo-package-promotion div.tab-content").hide();
	$(".combo-package-promotion div.tab-content[data-combo-id='"+data_combo_id+"']").show();
	$(".combo-package-promotion img.lazy_load").lazyload({
		threshold : 50,
		effect : "fadeIn", //淡入效果
	})
})

//计算阶梯优惠后的价格
function calculated_price(num, obj){
	if($(obj) == undefined) return;
	var goodsLadderPreferentialList = $("#goodsLadderPreferentialList").val();
	var arr = JSON.parse(goodsLadderPreferentialList);
	var price = parseFloat($(obj).attr("data-price"));
	if(arr.length > 0){
		for (var i = 0; i < arr.length; i++) {
			if(num >= arr[i]['quantity']){
				price -= arr[i]['price'];
				break;
			}
		}
	}
	$(obj).text("￥"+price.toFixed(2));
}
</script>